package mac10.models;

import de.dailab.jiactng.agentcore.knowledge.IFact;

public class Point implements IFact 
{

    /**
     * 
     */
    private static final long serialVersionUID = -3092268078675621567L;
    
    public static final Point ZERO = new Point(0,0);
    
    protected int x, y;
    
    public Point(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
    
    public Point(Point p)
    {
        this(p.x, p.y);
    }
    
    public int maxNorm(Point p)
    {
        return Math.max(Math.abs(this.x - p.x), Math.abs(this.y - p.y));
    }
    
    public double euklNorm(Point p)
    {
        int a = this.x - p.x;
        int b = this.y - p.y;
        return Math.sqrt(a*a + b*b);
    }
    
    public double euklScalarProduct(Point p)
    {
        return this.x*p.x+this.y*p.y;
    }
    
    public static int maxNorm(Point p1, Point p2)
    {
        return p1.maxNorm(p2);
    }

    public static double euklNorm(Point p1, Point p2)
    {
        return p1.euklNorm(p2);
    }

    public boolean equals(Object obj)
    {
        if(obj instanceof Point)
        {
            Point p = (Point) obj;
            if(p.x == this.x && p.y == this.y)
                return true;
        }
        return false;
    }

	public int hashCode()
	{
		return x*10000+y;
	}
    
	/**
     * @return the x
     */
    public int getX ()
    {
        return x;
    }

    /**
     * @param x the x to set
     */
    public void setX (int x)
    {
        this.x = x;
    }

    /**
     * @return the y
     */
    public int getY ()
    {
        return y;
    }

    /**
     * @param y the y to set
     */
    public void setY (int y)
    {
        this.y = y;
    }
    
    public String toString() {
        String cellInfo = "";
        cellInfo += "(" + x + ", " + y + ")";
        return cellInfo;
    }
    
}
